#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/1/25 22:58
# @Author  : Ramsey
# @Site    : zh
# @File    : run.py
# @Software: PyCharm
import time
import asyncio
from spider_framework.core.engine import Engine
from test.baidu_spider.spiders.baidu_homepage import BaiduHomePageSpider
from test.baidu_spider.spiders.baidu_keyword import BaiduKeywordSpider
from spider_framework.utils.project_settings import get_settings
from spider_framework.utils.crawler import StartUpCrawler


async def run():
    settings = get_settings("settings")
    # baidu_spider = BaiduSpider()
    # engine = Engine(settings=settings)
    # await engine.start_spider(spider_instance=baidu_spider)
    start_up_crawler = StartUpCrawler(settings)
    await start_up_crawler.crawl(BaiduHomePageSpider)
    # await start_up_crawler.crawl(BaiduKeywordSpider)
    await start_up_crawler.start()


if __name__ == "__main__":
    t1 = time.time()
    asyncio.run(run())
    print(f"总耗时: {time.time() - t1}")
